<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of test_cross3</title>
  <meta name="keywords" content="test_cross3">
  <meta name="description" content="">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">tests</a> &gt; test_cross3.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/tests&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>test_cross3
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong></strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>This is a script file. </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/cross/tt_rc.html" class="code" title="function [y]=tt_rc(d,n,elem_fun,eps,varargin)">tt_rc</a>	[Y]=TT_RC(D,N,ARR,ELEM_FUN,EPS,[OPTIONS])</li><li><a href="../../tt2/exp/Fd_mtx2.html" class="code" title="function [mat]=Fd_mtx2(a)">Fd_mtx2</a>	Finite difference approximation of a 2D scalar diffusion equation in QTT</li><li><a href="../../tt2/misc/lars.html" class="code" title="function [y]=lars(p,ind,mat,rhs,n,d,smin,h,i0,j0)">lars</a>	The dimension is p^2 (thus w</li><li><a href="lars.html" class="code" title="function [y]=lars(p,ind,mat,rhs,n,d,smin,h,i0,j0)">lars</a>	The dimension is p^2 (thus w</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 p=4;
0002 
0003 L=6; n=2^L-1; m=(n+1)/p; <span class="comment">%Step size</span>
0004 a=0;
0005 b=1;
0006 h=(b-a)/(n+1);
0007 
0008 
0009 <span class="comment">%a2=ones(n+1,n+1); %Values of a2 are defined at midpoints</span>
0010 <span class="comment">%a2(1:m,1:m)=10^4;</span>
0011 <span class="comment">%mat=Fd_mtx2(a2);</span>
0012 <span class="comment">%rhs=ones(n*n,1);</span>
0013 <span class="comment">%sol=mat \ rhs;</span>
0014 <span class="comment">%mesh(reshape(sol,n,n))</span>
0015 <span class="comment">%return</span>
0016 <span class="comment">%The solution is defined at points (1:n)/(n+1)</span>
0017 <span class="comment">%mat=Fd_mtx2(a2);</span>
0018 <span class="comment">%fprintf('after Fd_mtx2 \n');</span>
0019 <span class="comment">%keyboard;</span>
0020 <span class="comment">%The diffusion coefficient is defined at points (0.5:n+0.5)/(n+1);</span>
0021 xsol=(1:n)*h;
0022 xa=(0.5:n+0.5)*h;
0023 
0024 <span class="comment">%Generate right coefficient</span>
0025 
0026 a2=zeros(n+1,n+1);
0027 mat=[];
0028 <span class="keyword">for</span> i=1:p
0029   <span class="keyword">for</span> j=1:p
0030       tmp=zeros(n+1,n+1);
0031       tmp((i-1)*m+1:i*m,(j-1)*m+1:j*m)=1;
0032       a2=a2+tmp;
0033       mat{i+(j-1)*p}=<a href="../../tt2/exp/Fd_mtx2.html" class="code" title="function [mat]=Fd_mtx2(a)">Fd_mtx2</a>(tmp); 
0034   <span class="keyword">end</span>
0035 <span class="keyword">end</span>
0036 
0037 smin=1;
0038 smax=2;
0039 d=6;
0040 h=(smax-smin)/(2^d-1);
0041 rhs=ones(n*n,1);
0042 
0043 fun = @(ind) <a href="lars.html" class="code" title="function [y]=lars(p,ind,mat,rhs,n,d,smin,h,i0,j0)">lars</a>(p,ind,mat,rhs,n,d,smin,h,(n+1)/2,(n+1)/2);
0044 y=<a href="../../tt2/cross/tt_rc.html" class="code" title="function [y]=tt_rc(d,n,elem_fun,eps,varargin)">tt_rc</a>(p*p*d,2,fun,1e-5,<span class="string">'nswp'</span>,40,<span class="string">'change_dir_on'</span>,false);</pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>